xDS unified mux: subscription states#16486
xDS unified mux: subscription states#16486htuch merged 23 commits intoenvoyproxy:mainfrom dmitri-d:xds-unification-part-1
Conversation
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
|
Ping @adisuissa. I followed your suggestion re: how to split the original PR (#15473). |
|
/assign @adisuissa |
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
…t.cc Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
adisuissa
left a comment
There was a problem hiding this comment.
Thanks for improving this code.
I've left a few comments, mostly about possible refactoring that I think can be done.
| envoy::service::discovery::v3::DeltaDiscoveryRequest* | ||
| DeltaSubscriptionState::getNextRequestInternal() { | ||
| auto* request = new envoy::service::discovery::v3::DeltaDiscoveryRequest; | ||
| request->set_type_url(type_url()); |
There was a problem hiding this comment.
previously, in addition to type_url, the request's node field was also updated. Why was this removed here?
Also it seems that this is something that should be generic for both Delta/SotW variants, and should be set in the parent class.
There was a problem hiding this comment.
This bit is handled by mux (here: https://github.com/envoyproxy/envoy/pull/15473/files#diff-fe56236f0649ba734162e4fa294465a6004c393242c0af89421cbd5fe279fe58R341 and here: https://github.com/envoyproxy/envoy/pull/15473/files#diff-fe56236f0649ba734162e4fa294465a6004c393242c0af89421cbd5fe279fe58R398) in the new implementation, although I think you are right, conceptually it fits better with the state. I'd like to postpone this change until the PR that introduces new mux implementation, however: it's a bit tricky to keep track of changes that affect multiple classes and more importantly the logic inside. I can add a comment to that effect?
In current implementation sotw and delta muxes handle node differently (delta always sends node), the new implementation uses the approach currently used by sotw mux in both cases.
| // pointer actually is. | ||
| virtual RQ* getNextRequestWithAck(const UpdateAck& ack) PURE; | ||
|
|
||
| void disableInitFetchTimeoutTimer() { |
There was a problem hiding this comment.
It seems that enabling the timer only happens during the object initialization, and then disable can be called, and there's no way to re-enable the timer. Is this intended behavior? Can you add a comment why it behaves so?
There was a problem hiding this comment.
This only handles initial fetch timeout. Currently this is handled in the subscription (here: https://github.com/envoyproxy/envoy/blob/main/source/common/config/grpc_subscription_impl.cc#L31), but has been moved to subscription state in the new implementation. Added a comment, please let me know if it's descriptive enough.
There was a problem hiding this comment.
What's the rationale for the move?
There was a problem hiding this comment.
It was moved in the original version of this work done by Fred, and I thought it was a good call. I just noticed though that this introduced a problem under Ads: should any subscription sharing mux with other subscriptions call GrpcMux::disableInitFetchTimeoutTimer() (here: 109ac32#diff-fe56236f0649ba734162e4fa294465a6004c393242c0af89421cbd5fe279fe58R183), all subscriptions will get their init fetch timeout timers disabled. I don't think there's a way around this, I'll move the timer and corresponding calls back to subscription.
| void setDynamicContextChanged() { dynamic_context_changed_ = true; } | ||
| void clearDynamicContextChanged() { dynamic_context_changed_ = false; } | ||
| bool dynamicContextChanged() const { return dynamic_context_changed_; } |
There was a problem hiding this comment.
Should these be protected instead of public?
There was a problem hiding this comment.
Probably not atm: these are called from mux (here: https://github.com/envoyproxy/envoy/pull/15473/files#diff-fe56236f0649ba734162e4fa294465a6004c393242c0af89421cbd5fe279fe58R41 and https://github.com/envoyproxy/envoy/pull/15473/files#diff-fe56236f0649ba734162e4fa294465a6004c393242c0af89421cbd5fe279fe58R351)
| Protobuf::RepeatedPtrField<std::string> removed_resources; | ||
| for (const auto& resource : expired) { | ||
| resource_state_[resource] = ResourceState::waitingForServer(); | ||
| removed_resources.Add(std::string(resource)); |
There was a problem hiding this comment.
Why is the call to the string c'tor required here?
There was a problem hiding this comment.
This is a port from here: https://github.com/envoyproxy/envoy/blob/main/source/common/config/delta_subscription_state.cc#L22. My understaning is that Protobuf::RepeatedPtrField takes ownership of strings/massages added to it, hence the signature (RepeatedPtrField<T>::Add(T&& value)) and the need for a new instance of the string.
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
adisuissa
left a comment
There was a problem hiding this comment.
Looks good, thanks!
One more comment about the tests.
| std::unique_ptr<Envoy::Config::DeltaSubscriptionState> legacy_state_; | ||
| std::unique_ptr<Envoy::Config::UnifiedMux::DeltaSubscriptionState> unified_state_; |
There was a problem hiding this comment.
Should these be a variant?
If there's no use of both at the same time, I think it makes sense.
|
/cc @htuch |
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
|
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
|
|
Not sure why the coverage for source/common/config/unified_mux is reported so low; I have it at 96.5% locally. |
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
|
If you check https://github.com/envoyproxy/envoy/blob/main/source/docs/coverage.md it should show you what's missing |
|
Yan: can you cover code reviews until @htuch gets back? |
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
|
@adisuissa: discovered an issue with how I was handling ttl resources in SotW; fixed now. Also expanded test coverage. |
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
|
ping @yanavlasov |
|
@htuch: any chance you could take a look? |
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
| class SubscriptionState : public Logger::Loggable<Logger::Id::config> { | ||
| public: | ||
| // Note that, outside of tests, we expect callbacks to always be a WatchMap. | ||
| SubscriptionState(std::string type_url, UntypedConfigUpdateCallbacks& callbacks, |
There was a problem hiding this comment.
Nit: const std::string& or absl::string_view
There was a problem hiding this comment.
please see the comment below.
| // pointer actually is. | ||
| virtual RQ* getNextRequestWithAck(const UpdateAck& ack) PURE; | ||
|
|
||
| void disableInitFetchTimeoutTimer() { |
There was a problem hiding this comment.
What's the rationale for the move?
| : public SubscriptionState<envoy::service::discovery::v3::DeltaDiscoveryResponse, | ||
| envoy::service::discovery::v3::DeltaDiscoveryRequest> { | ||
| public: | ||
| DeltaSubscriptionState(std::string type_url, UntypedConfigUpdateCallbacks& watch_map, |
There was a problem hiding this comment.
Nit: can you check all the places you are passing strings as args and move them to refs/string_views?
There was a problem hiding this comment.
I checked string parameters in ctors. In ctor implementations, the initial copy is being moved all the way to the base class member initialization (here: https://github.com/envoyproxy/envoy/pull/16486/files#diff-807032428ceb00bb04de1be63707b2ae3dccaa00912341208fd4b8da55993b17R38).
There was a problem hiding this comment.
I guess this is OK, but it's a bit counter-intuitive to someone reading the interface. Usually prefer to pass by reference and then leave the copy internally.
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
|
Split out subscription state out of xDS mux unification PR (envoyproxy#15473). Made base subscription state class a template. Updated existing delta state tests to work with both legacy and new implementations. Risk Level: low, the code is not being used atm Testing: updated existing tests, added new ones Signed-off-by: Dmitri Dolguikh <ddolguik@redhat.com>
Split out subscription state out of xDS mux unification PR (#15473). Made base subscription state class a template. Updated existing delta state tests to work with both legacy and new implementations.
Commit Message: xDS unified mux: subscription states
Additional Description:
Risk Level: low, the code is not being used atm
Testing: updated existing tests, added new ones
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]